import { BasicColumn, FormSchema } from '/@/components/Table';

const statusOptions = [
  { label: '未履行', value: 1 },
  { label: '履行中', value: 2 },
  { label: '已结束', value: 3 },
  { label: '提前终止', value: 4 },
];
const TypeOptions = [
  { label: '办公区域', value: 1 },
  { label: '设备', value: 2 },
];
const payOptions = [
  { label: '支付宝', value: 1 },
  { label: '微信', value: 2 },
  { label: '银行转账', value: 3 },
  { label: '现金', value: 4 },
  { label: '银联支付', value: 5 },
  { label: '其他', value: 6 },
];
export const columns: BasicColumn[] = [
  {
    title: '合同名称',
    dataIndex: 'contractName',
  },
  {
    title: '租赁类型',
    dataIndex: 'type',
    customRender({ text }) {
      const find = TypeOptions.find((opt) => opt.value === text);
      return find?.label || '未定义';
    },
  },
  {
    title: '合同状态',
    dataIndex: 'status',
    customRender({ text }) {
      const find = statusOptions.find((opt) => opt.value === text);
      return find?.label || '未知';
    },
  },
  {
    title: '文件地址',
    dataIndex: 'fileUrl',
  },
  {
    title: '合同开始时间',
    dataIndex: 'startDate',
  },
  {
    title: '合同结束时间',
    dataIndex: 'endDate',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '合同名称',
    field: 'contractName',
    component: 'JInput',
  },
  {
    label: '租赁类型',
    field: 'type',
    component: 'Select',
    componentProps: {
      options: TypeOptions,
    },
  },
  {
    label: '合同状态',
    field: 'status',
    component: 'Select',
    componentProps: {
      options: statusOptions,
    },
  },
];

export const formSchema: FormSchema[] = [
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '合同名称',
    field: 'contractName',
    component: 'Input',
    required: true,
  },
  {
    label: '合同状态',
    field: 'status',
    component: 'Select',
    defaultValue: 1,
    componentProps: {
      options: statusOptions,
    },
    required: true,
  },
  {
    label: '租赁类型',
    field: 'assetType',
    component: 'Select',
    defaultValue: 1,
    componentProps: {
      options: TypeOptions,
    },
    required: true,
  },
  {
    label: '租赁资源(办公)',
    field: 'resourceId',
    component: 'Input',
    ifShow: ({ values }) => {
      return [1].includes(values.assetType);
    },
    required: true,
  },
  {
    label: '租赁资源(设备)',
    field: 'resourceId',
    component: 'Input',
    ifShow: ({ values }) => {
      return [2].includes(values.assetType);
    },
    required: true,
  },
  // {
  //   label: '*********文件地址',
  //   field: '',
  //   component: 'Input',
  // },
  {
    field: 'fileUrl',
    component: 'JUpload',
    helpMessage: '最多上传1个文件',
    label: '上传文件（1）',
    componentProps: { maxCount: 1 },
  },
  {
    field: 'startDate',
    label: '合同开始时间',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    colProps: { span: 15 },
  },
  {
    field: 'endDate',
    label: '合同结束时间',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    colProps: { span: 15 },
  },
  {
    label: '合同总金额',
    field: 'totalAmount',
    component: 'Input',
    required: false,
  },
  {
    label: '实际支付金额',
    field: 'payAmount',
    component: 'Input',
    required: false,
  },
  {
    field: 'payDate',
    label: '支付时间',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    colProps: { span: 15 },
  },
  {
    label: '支付方式',
    field: 'payMethod',
    component: 'Select',
    defaultValue: 1,
    componentProps: {
      options: payOptions,
    },
    required: true,
  },
  {
    label: '租赁方公司名称',
    field: 'tenantName',
    component: 'Input',
    required: false,
  },
  {
    label: '租赁方姓名',
    field: 'contactName',
    component: 'Input',
    required: false,
  },
  {
    label: '租赁方电话',
    field: 'phone',
    component: 'Input',
    required: false,
  },
  {
    label: '租赁方邮箱',
    field: 'email',
    component: 'Input',
    required: false,
  },
  {
    label: '退款金额',
    field: 'refundAmount',
    component: 'Input',
    required: false,
  },
  {
    label: '退款相关描述',
    field: 'refundRemark',
    component: 'Input',
    required: false,
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
    required: false,
  },
];
